package com.leaf.lowcode.utils.jsontobean;

import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateToTransfer<T> implements ToTranfer<T> {
    @Override
    public T laod(Field field, Object o, T cls) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
        Date ts = null;
        try {
            ts = sdf.parse((String) o);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        System.out.println(o);
        try {
            field.setAccessible(true);
            field.set(cls, ts);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return cls;
    }
}
